package net.lzzy.chapter13;

public class BoundedTypeDemo {
    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle(2,2);
        Circle circle = new Circle(2);
        /* 椭圆*/
        Ellipse ellipse = new Ellipse(1,3);

        System.out.println("Same area?" +
                equalArea(rectangle,circle));

        System.out.println("两个面积是否相等" +
                equalArea(circle,ellipse));

        System.out.println("两个周长是否相等" +
                equalPerimeter(circle,ellipse));
    }

    public static <E extends GeometricObject> boolean equalArea(
            E object1, E object2){
        return object1.getArea() == object2.getArea();
    }

    /* 使用周长作为判断 */
    public static <E extends GeometricObject> boolean equalPerimeter(
            E object1, E object2){
        return object1.getPerimeter() == object2.getPerimeter();
    }
}
